#ifndef _RUN_H
#define _RUN_H

#include "basic.h"

#include "wifi.h"
#include "motion.h"
#include "oled.h"
#include "led.h"

//Light light(255);
Motion motion(D0, D1, D2, D3);
Oled oled;
Web web;

void sleep()
{
  if (!isSleep)
  {
    //light.turnOff();
    motion.takeBackLegs(); // 注意 这个函数是阻塞函数
    isSleep = true;
    run_code = WAITING;
    isMotionReset = false;
  }
  oled.lookSecrately();
}

void happy()
{
  //light.sameDirectionCommonColorRainbowFlow();
  oled.play1024Image(gImage_happy1);
  motion.swingBackAndFront(30);
}

void webRun()
{
  isSleep = false;
  // web handle
  web.handleRequest();

  // led handel
  //light.runLight();

  // oled handle
oled.runEmoji();

  // servo handle
  motion.run();
}

#endif